<?php
namespace Admin\Controller;
use Think\Controller;
/**
* GuestemailController
*/
class GuestemailController extends CommonController
{
	
	//询盘邮箱管理
	public function index(){
		$list=M("guestemail")->select();
		$this->assign("list",$list);
		$this->display();
	}

	public function add(){
		if (IS_POST) {
			$data = I('post.');
			$data['addtime']=time();
			if(M("guestemail")->add($data)){
				alertMes('添加成功','/admin/guestemail/index');
			}else{
				alertMes('添加失败','/admin/guestemail/index');
			}
		}
		$this->display();
	}

	public function del(){
		$id        = I('id', 0, 'intval');
        //执行删除
        if (!$id) {
            alertMes('参数错误');
        }
        //执行删除
        if (false !== M('guestemail')->delete($id)) {
            alertMes('删除成功','/admin/guestemail/index');
        } else {
            alertMes('删除失败');
        }
	}
    
    public function edit(){
    	$id = I('id', 0, 'intval');
        if (IS_POST) {
            $data            = I('post.');
            if (false !== M('guestemail')->save($data)) {
                alertMes('修改成功','/admin/guestemail');
            } else {
                alertMes('修改失败');
            }
        }
        $list = M('guestemail')->find($id);
        $this->assign('list', $list);
        $this->display();
    }

}